package com.atguigu.sort;

import com.sun.javafx.scene.control.skin.VirtualFlow;
import com.sun.org.apache.xerces.internal.util.EntityResolverWrapper;
import sun.misc.Queue;

import java.util.*;

/**
 * Create with Intellij IDEA.
 * Description：
 * User:Zero
 * Date:2021/6/9
 * Time:13:58
 */
public class BubbleSort1 {
    public static void main(String[] args) {
//        int []arr ={4,1,2,6,7,5,3,8,9,10};
////      _Bubble(arr);
//        int target=5;
//        System.out.println(_Search(arr, target));
////      for (int i:arr)
////      System.out.println(i);
//        System.out.println(Math.round(-1.6));
//        System.out.println(Math.round(0.5));
        /**
         * indexOf()：返回指定字符的索引。
         * charAt()：返回指定索引处的字符。
         * replace()：字符串替换。
         * trim()：去除字符串两端空白。
         * split()：分割字符串，返回一个分割后的字符串数组。
         * getBytes()：返回字符串的 byte 类型数组。
         * length()：返回字符串长度。
         * toLowerCase()：将字符串转成小写字母。
         * toUpperCase()：将字符串转成大写字符。
         * substring()：截取字符串。
         * equals()：字符串比较
         */
        String s = "ChongQingShi_hanfugui";
        String s1 ="ChongQingShi_hanfugui";
        String s2 = new String("ChongQingShi_hanfugui");
        System.out.println(s.equals(s1));
        System.out.println(s.equals(s2));

        System.out.println(s.substring(0, 5));

        /*byte[] bytes = s.getBytes();
        for (byte b: bytes){
            System.out.print(b+" ");
        }*/
       /* String[] split = s.split("_");
        System.out.println(split[0]);
        System.out.println(split[1]);*/

//        System.out.println(s.trim());
        System.out.println("原有的字符串:"+s);
        System.out.println(s.charAt(2));
        System.out.println(s.indexOf('h'));
    }

    private static int _Search(int[] arr, int target) {
          Arrays.sort(arr);
          int left=0,right = arr.length-1;
          int temp;
          while (left<right){
              temp = (left+right)/2;
              if (arr[temp]==target)
                  return temp+1;
              if (arr[temp]>target){
                  right = temp;
              }else {
                  left = temp;
              }
          }
          return -1;
    }


    /**
     * 冒泡排序
     * @param arr
     */
    private static void _Bubble(int[] arr) {
        int temp;
        for (int i=0;i<arr.length;i++){
            for (int j=i;j<arr.length;j++) {
                if (arr[i]>arr[j]){
                   temp = arr[i];
                   arr[i] = arr[j];
                   arr[j] = temp;
                }
            }
        }
    }


}

abstract class  Person{
    public  void  say(){
        System.out.println("hahha");
    }
    abstract public void eat();
}

class Student extends Person implements Animal{
    @Override
    public void eat() {
        System.out.println("eat");
    }
}
class  test{
    public static void main(String[] args) throws InterruptedException {
//        Person person = new Student();
//        person.say();
//        Animal animal = new Student();
//        animal.sayAnimal();

        /*HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("a","Hanfugui");
        hashMap.put("b","Zero");
        Set<String> strings = hashMap.keySet();
        for (String s : strings){
            System.out.println(hashMap.get(s));
        }

        Queue<String> queue = new Queue<>();
        queue.enqueue("a");
        queue.enqueue("b");
        System.out.println(queue.dequeue());*/

        LinkedList<String> linkedList = new LinkedList<>();
        linkedList.add("a");
        linkedList.add("b");
        linkedList.add("c");
        Iterator<String> iterator = linkedList.iterator();
        while (iterator.hasNext()){
            String s = iterator.next();
            System.out.println(s);
        }
        for (String s:linkedList){
            System.out.println(s);
        }
        for (int i = 0; i < linkedList.size(); i++) {
            System.out.println(linkedList.get(i));
        }

    }
}
interface Animal{
    default void sayAnimal(){
        System.out.println("say");
    }
}
